package learn.java.basic.net;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class LocalDatagrameSocketClient {
    public static void main(String[] args) throws IOException {

        //1,既然要进行udp协议的网络通信，当然要建立udp的socket服务.
        DatagramSocket ds = new DatagramSocket();

        Scanner scanner = new Scanner(System.in);
        byte[]bytes=new byte[65535];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length, InetAddress.getByName("192.168.96.100"),20002);

        while (true){
            String s = scanner.nextLine();
            dp.setData(s.getBytes());
            ds.send(dp);
        }


    }

}
